//
//  HRStore.h
//  APJ Resource
//
//  Created by Richard Zhao on 1/23/14.
//  Copyright (c) 2014 APJ. All rights reserved.
// A

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class User;
@class Staff;
@class Dept;
@class Project;
@class ResourceRequirement;

@interface HRStore : NSObject
{
    NSMutableArray *allStaffs;
    NSMutableArray *allDepts;
    NSManagedObjectContext *context;
    NSManagedObjectModel *model;
}

+ (HRStore *)sharedStore;
- (BOOL)syncTable:(NSString *)tableName withData:(NSArray *)datas byKeys:(NSArray *)keys ;
- (BOOL)syncFromActionLog:(NSString *)tableName withData:(NSArray *)datas byKeys:(NSArray *)keys ;

- (User *)findUserById:(NSString *)uid;
- (NSArray *)allDept;
- (NSArray *)allSkillCategory;
- (NSArray *)skillUnderCategory:(NSString *)skillCategory;
- (NSArray *)allSkillsOfStaff:(int)staffId;
-(NSArray *)allSkillCategoryForActive;
- (NSArray *)educationOfStaff:(int)staffId;
- (NSArray *)interviewOfStaff:(int)staffId;
- (NSArray *)workExperienceOfStaff:(int)staffId;
- (NSArray *)qualificationOfStaff:(int)staffId;
- (NSArray *)skillsOfStaff:(int)staffId;
- (NSArray *)projectAssignToStaff:(int)staffId;
- (NSArray *)projectAssignFroProject:(int)projectId;
- (NSString *)allSkillsStringOfStaff:(int)staffId;
-(NSArray *)allSkillsOfCategory:(NSString *)skillCategoryCode;
- (NSArray *)findStaffAboutName:(NSString *)name inDept:(int)dept withSkills:(NSArray *)skills withStaffState:(NSString *)state;
- (NSArray *)findProjectAboutName:(NSString *)name inDept:(int)dept;
- (Dept *)findDeptById:(int)deptId;
- (Project *)findProjectById:(int)projectId;
- (Staff *)findStaffById:(int)staffId;
- (NSArray *)reqByDept:(int)deptId inMonth:(NSTimeInterval)theMonth;

-(NSArray *)positionRequirementsByDept:(int)deptId inMonth:(NSTimeInterval)theMonth position:(NSString *)positionValue;

-(NSArray *)getLegacyRequirementsByDept:(int)deptId inMonth:(NSTimeInterval)theMonth  position:(NSString *)positionValue;


- (NSArray *)confirmedInterviewForReq:(int)reqId;
- (NSArray *)confirmedInterviewForReqAndPosition:(int)reqId position:(NSString *)positionValue;


- (NSArray *)interviewOfReqId:(int)reqId;
-(ResourceRequirement *)ResourceRequirementByReqId:(int)reqId;

-(NSArray *) resourceRequirementSkillMatrix:(NSString *)skillCode ;

- (NSArray *) requirementFromSkillCode:(NSString *)skillCode  inMonth:(NSTimeInterval)theMonth position:(NSString *)positionValue;
- (NSArray *) requirementFromSkillCodeForLegacy:(NSString *)skillCode inMonth:(NSTimeInterval)theMonth position:(NSString *)positionValue;

//更具SkillCode获取ResourceRequirement中当前月份的需求
- (NSArray *) GetRequirementFromSkillCodeAndPositionInCurrentMonth:(NSString *)skillCode  inMonth:(NSTimeInterval)theMonth  position:(NSString *)positionValue;
//更具SkillCode获取ResourceRequirement中当前月份之前的需求
- (NSArray *) GetRequirementFromSkillCodeAndPositionInCurrentMonthForLegacy:(NSString *)skillCode  inMonth:(NSTimeInterval)theMonth  position:(NSString *)positionValue;

//从SystemCode获取技能列表(codeTypeId=7)
-(NSArray *)GetSkillFromSystemCode;

- (NSArray *)reqBySkill:(NSString *)skillCode inMonth:(NSTimeInterval)theMonth;

- (NSArray *)reqBySkillAndOutstanding:(NSString *)skillCode inMonth:(NSTimeInterval)theMonth;

- (NSArray *)reqBydeptAndOutstanding:(int)deptId inMonth:(NSTimeInterval)theMonth;

-(NSArray *)getCurrentMonthconfirmedInterviewForReq:(int)reqId inMonth:(NSTimeInterval)theMonth;
- (NSArray *)getLegacyconfirmedInterviewForReq:(int)reqId inMonth:(NSTimeInterval)theMonth;


@end
